import { createRouter, createWebHashHistory } from "vue-router";
import Login from "@/pages/login.vue";

export const routes = [
  {
    path: "/",
    redirect: "/index",
  },
  {
    name: "login",
    path: "/login",
    component: Login,
  },
  {
    name: "index",
    path: "/index",
    component: () => import("@/pages/index.vue"),
    // redirect: "/user",
    children: [
      {
        path: "/user",
        component: () => import("@/pages/user/index.vue"),
        name: "user", // 用于 keep-alive, 必须与SFC自动推导或者显示声明的组件name一致
        // redirect: "/note",
        children: [ ],
      },
    ],
  },
];
const router = createRouter({
  scrollBehavior: () => ({ left: 0, top: 0 }),
  history: createWebHashHistory(),
  routes,
});
router.beforeEach((to, from, next) => {
  console.log('beforeEach-to', to);
  console.log('beforeEach-from', from);
  next();
});
export default router;
